﻿<UserControl x:Class="Client.View.FizickoLiceView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:Client.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="250" d:DesignWidth="300"
             MinWidth="600"
             >

    <UserControl.Resources>
        <ResourceDictionary>
            <converters:PolConverter x:Key="PolConverter"/>
            <converters:OceviCboxConverter x:Key="OceviCboxConverter"/>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid TextElement.Foreground="DarkBlue" TextElement.FontSize="16">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!--###############################-->
        <!--old binding-->
        <!--explicit assign in NewWindow ctor must be done for this-->
        <!--<TextBox Text="{Binding ObjectToPersist.Prezime, Mode=TwoWay}" Grid.Column="1" Grid.Row="1" />-->
        <!--###############################-->

        <TextBlock Text="Ime:" Grid.Column="0" VerticalAlignment="Center"/>
        <TextBox Text="{Binding Ime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" 
                 Validation.ErrorTemplate="{StaticResource ValidationTemplate1}" Grid.Column="1"/>

        <TextBlock Text="Prezime:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"/>
        <TextBox Text="{Binding Prezime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" 
                 Grid.Column="1" Grid.Row="1"  Validation.ErrorTemplate="{StaticResource ValidationTemplate1}"/>

        <TextBlock Text="JMBG:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center"/>
        <TextBox Text="{Binding IdentifikacioniBroj, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                 Grid.Column="1" Grid.Row="2"  Validation.ErrorTemplate="{StaticResource ValidationTemplate1}"/>

        <TextBlock Text="Pol:" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center"/>
        <ComboBox Name="cboxGender"
                  Margin="5" 
                  ItemsSource="{Binding Polovi}"
                  SelectedItem="{Binding Pol, Mode=TwoWay}"                 
                  Grid.Column="1" Grid.Row="3">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={StaticResource PolConverter}}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock Text="Datum rodjenja:" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center"/>
        <DatePicker Grid.Row="4" Grid.Column="1" Margin="5,2,2,2" BorderBrush="#FF333333" BorderThickness="2" 
                    SelectedDate="{Binding DatumRodjenja, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                    Validation.ErrorTemplate="{StaticResource ValidationTemplate1}">
        </DatePicker>

        <TextBlock Text="Otac:" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center"/>
        <ComboBox Name="cboxFather"
                  Margin="5" 
                  ItemsSource="{Binding MuskaFizickaLica}"
                  SelectedItem="{Binding DataContext.CurrentPageViewModel.ObjectToPersist.Otac, Mode=TwoWay,RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
                  SelectedIndex="{Binding SelIndexOtac}"
                  Grid.Column="1" Grid.Row="5">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Margin="0,0,10,0" Width="48" Height="48" Source="{Binding Slika}" />
                        <TextBlock VerticalAlignment="Center" Text="{Binding Converter={StaticResource OceviCboxConverter}}"/>
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock Text="Majka:" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center"/>
        <ComboBox Name="cboxMother"
                  Margin="5" 
                  ItemsSource="{Binding ZenskaFizickaLica}"
                  SelectedItem="{Binding DataContext.CurrentPageViewModel.ObjectToPersist.Majka, Mode=TwoWay,RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
                  SelectedIndex="{Binding SelIndexMajka}"
                  Grid.Column="1" Grid.Row="6" Opacity="0.9">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Margin="0,0,10,0" Width="48" Height="48" Source="{Binding Slika}" />
                        <TextBlock VerticalAlignment="Center" Text="{Binding Converter={StaticResource OceviCboxConverter}}"/>
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
    </Grid>
</UserControl>
<!--SelectedItem="{Binding DataContext.CurrentPageViewModel.ObjectToPersist.Pol, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"-->